<%@ Page Language="C#" AutoEventWireup="true" CodeFile="dstb.aspx.cs" Inherits="Telerik.GridExamplesCSharp.DataEditing.AllEditableColumns.thongtinkhac_dstb" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Untitled Page</title>
     <style type="text/css">
        .MyImageButton
        {
           cursor: hand;
        }
        .EditFormHeader td
        {
            font-size: 14px;
            padding: 4px !important;
            color: #0066cc;
        }
        </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        
            <p id="divMsgs" runat="server">
        <asp:Label ID="Label1" runat="server" EnableViewState="False" Font-Bold="True" ForeColor="#FF8080"></asp:Label>
        <asp:Label ID="Label2" runat="server" EnableViewState="False" Font-Bold="True" ForeColor="#00C000"></asp:Label>
            </p>
            
         <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

            <script type="text/javascript">
            function RowDblClick(sender, eventArgs)
            {
              sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
            }
            </script>

        </telerik:RadCodeBlock>
        <!-- load ajax-->
         <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid_Xlsp">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid_XLsp" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="divMsgs" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
        </telerik:RadAjaxManager>
        <!-- end-->
        
        
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" 
            BackColor="#99FF66" Skin="WebBlue" />
        <telerik:RadGrid ID="RadGrid_XLsp" runat="server" AllowPaging="True" 
            AllowSorting="True" CellSpacing="0" DataSourceID="SqlDataSource_sp1" 
            GridLines="None" AllowAutomaticDeletes="True" AutoGenerateColumns="False"
            AllowAutomaticInserts="True" AllowAutomaticUpdates="True" OnItemUpdated="RadGrid_XLsp_ItemUpdated"
             
           OnItemInserted="RadGrid_XLsp_ItemInserted" OnDataBound="RadGrid_XLsp_DataBound" Skin="Telerik">
                <HeaderContextMenu></HeaderContextMenu>

                <MasterTableView AutoGenerateColumns="False" DataKeyNames="mstb" 
                                DataSourceID="SqlDataSource_sp1" CommandItemDisplay="Top">
                                
                <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>

                <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                <HeaderStyle Width="20px"></HeaderStyle>
                </RowIndicatorColumn>

                <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                <HeaderStyle Width="20px"></HeaderStyle>
                </ExpandCollapseColumn>

    <Columns>
    <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                        <ItemStyle CssClass="MyImageButton" />
                    </telerik:GridEditCommandColumn>
                    
        <telerik:GridBoundColumn DataField="mstb" DataType="System.Int32"  Visible="false"
            FilterControlAltText="Filter mstb column" HeaderText="mstb" ReadOnly="True" 
            SortExpression="mstb" UniqueName="mstb">
        </telerik:GridBoundColumn>
        
           <telerik:GridTemplateColumn HeaderText="STT">
                       <ItemTemplate>
                        <asp:Label runat="server" ID="lblSTT" Text='<%#i++%>'></asp:Label>
                       </ItemTemplate>
           </telerik:GridTemplateColumn>
        
       
        
        <telerik:GridDropDownColumn DataField="Madnghiep" DataSourceID="sp_dn"
                        HeaderText="Doanhnghiep" ListTextField="TenDN" ListValueField="Madnghiep"
                        UniqueName="Madnghiep" ColumnEditorID="GridDropDownColumnEditor1">
        </telerik:GridDropDownColumn>
        
        <telerik:GridBoundColumn DataField="Nam" 
            FilterControlAltText="Filter Nam column" HeaderText="Nam" 
            SortExpression="Nam" UniqueName="Nam">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Thietbi" 
            FilterControlAltText="Filter Thietbi column" HeaderText="Thiet bi" SortExpression="Thietbi" 
            UniqueName="Thietbi">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Soluong" 
            FilterControlAltText="Filter Thang column" HeaderText="So luong" 
            SortExpression="Soluong" UniqueName="Soluong">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Congsuat" 
            FilterControlAltText="Filter Congsuat column" HeaderText="Cong suat" 
            SortExpression="Congsuat" UniqueName="Congsuat">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Donvi" 
            FilterControlAltText="Filter Donvi column" HeaderText="Don vi" 
            SortExpression="Donvi" UniqueName="Donvi">
        </telerik:GridBoundColumn>
        
        
        <telerik:GridButtonColumn ConfirmText="Delete this sanpham?" ConfirmDialogType="RadWindow"
                        ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                        UniqueName="DeleteColumn">
                        <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                    </telerik:GridButtonColumn>
    </Columns>

            <EditFormSettings EditFormType="Template" ColumnNumber="2" CaptionDataField="Madnghiep" CaptionFormatString="Edit properties of Product {0}" InsertCaption="New Sanpham">
            
<EditColumn UniqueName="EditCommandColumn1" FilterControlAltText="Filter EditCommandColumn1 column"></EditColumn>
            
                <FormTemplate>
                
    <table id="Table2" cellspacing="2" cellpadding="1" width="100%" border="0" rules="none"
    style="border-collapse: collapse; background: white;" >
        <tr class="EditFormHeader">
            <td colspan="2" style="font-size: small">
                    <b>Nhap thong tin: DANH SACH THIET BI</b>
            </td>
        </tr>                      
                        
        <tr>
            <td>
            <table id="Table3" cellspacing="1" cellpadding="1" width="100%" border="0" class="module">
                <tr>
                <td>Doanh nghiep:</td>
                <td>
                    <asp:DropDownList ID="DropDownList1" runat="server" SelectedValue='<%# Bind("Madnghiep") %>'
        DataTextField="TenDN" TabIndex="7" DataValueField="Madnghiep" DataSourceID="sp_dn" AppendDataBoundItems="True">
                    <asp:ListItem Selected="True" Text="Select" Value=""></asp:ListItem>
                    </asp:DropDownList>
                </td>
                </tr>
                <tr>
                <td>Nam:</td>
                <td>
                 <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Nam") %>'></asp:TextBox>   
                </td>
                </tr>
                <tr>
                <td>Thiet bi:</td>
                <td>
                <telerik:RadComboBox ID="cb_tb" runat="server" Skin="Hay">
                <Items>
                    <telerik:RadComboBoxItem runat="server" Text="Thiet bi 1" 
                        Value="Thiet bi 1" />
                    <telerik:RadComboBoxItem runat="server" Text="Thiet bi 2" 
                        Value="Thiet bi 2" />
                    <telerik:RadComboBoxItem runat="server" Text="Thiet bi 3" Value="Thiet bi 3" />
                    <telerik:RadComboBoxItem runat="server" Text="Thiet bi 4" Value="Thiet bi 4" />
                </Items>
            </telerik:RadComboBox> 
                </td>
                </tr>
                <tr>
                <td>So luong:</td>
                <td>
                <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Soluong") %>'></asp:TextBox>
                </td>
                </tr>
                <tr>
                <td>Cong suat:</td>
                <td>
                <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Congsuat") %>'></asp:TextBox>
                </td>
                </tr>
                <tr>
                <td>Don vi:</td>
                <td>
                <telerik:RadComboBox ID="cb_dv" runat="server" Skin="Hay">
                <Items>
                    <telerik:RadComboBoxItem runat="server" Text="don vi 1" 
                        Value="don vi 1" />
                    <telerik:RadComboBoxItem runat="server" Text="don vi 2" 
                        Value="don vi" />
                    <telerik:RadComboBoxItem runat="server" Text="don vi 3" Value="don vi 3" />
                    <telerik:RadComboBoxItem runat="server" Text="don vi 4" Value="don vi 4" />
                </Items>
            </telerik:RadComboBox> 
                </td>
                </tr>
                                </table>
                            </td>
                          
                            <td>
                               
                            </td>
                            </tr>
                         
                        <tr>
                            <td align="right" colspan="2">
                                 <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                    runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                                </asp:Button>&nbsp;
                                        <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                        CommandName="Cancel"></asp:Button>
                                  
                                 
                            </td>
                        </tr>
                    </table>
                </FormTemplate>
            </EditFormSettings>
           </MasterTableView>
           <ClientSettings EnableRowHoverStyle="true">
               <Selecting AllowRowSelect="True" />
               <ClientEvents OnRowDblClick="RowDblClick" />
           </ClientSettings>


<FilterMenu EnableImageSprites="False"></FilterMenu>
        </telerik:RadGrid>
        <asp:SqlDataSource ID="SqlDataSource_sp1" runat="server"
          ConnectionString="<%$ ConnectionStrings:QLMTConnectionString %>" ProviderName="System.Data.SqlClient"
          SelectCommand="SELECT * from Thietbi where Madnghiep=@Madnghiep"
           DeleteCommand="DELETE FROM [Thietbi] WHERE [mstb] = @original_mstb"
           InsertCommand="INSERT INTO Thietbi(Madnghiep, Nam,Thietbi,Soluong,Congsuat,Donvi) VALUES (@Madnghiep,@Nam,@Thietbi,@Soluong,@Congsuat,@Donvi)"
           UpdateCommand="UPDATE [Thietbi] SET [Madnghiep] = @Madnghiep, [Nam] = @Nam,[Thietbi]=@Thietbi, [Soluong] = @Soluong,[Congsuat]=@Congsuat,[Donvi]=@Donvi WHERE [mstb] = @original_mstb"
           
          OldValuesParameterFormatString="original_{0}" ConflictDetection="CompareAllValues">
         
          <SelectParameters>
        <asp:QueryStringParameter Name="Madnghiep" QueryStringField="_iddn"  ConvertEmptyStringToNull="true"/>
     </SelectParameters> 
          <DeleteParameters>
               <asp:Parameter Name="original_mstb" Type="Int32" />
           </DeleteParameters>
           <UpdateParameters>
               <asp:Parameter Name="Madnghiep" Type="Int32" />
               <asp:Parameter Name="Nam" Type="String" />
               <asp:Parameter Name="Thietbi" Type="String" />
               <asp:Parameter Name="Soluong" Type="String" />
               <asp:Parameter Name="Congsuat" Type="String" />
               
               <asp:Parameter Name="Donvi" Type="String" />
               
               <asp:Parameter Name="original_mstb" Type="Int32" />
               
               
           </UpdateParameters>
           <InsertParameters>                
               
               <asp:Parameter Name="Madnghiep" Type="Int32" />
               <asp:Parameter Name="Nam" Type="String" />
               <asp:Parameter Name="Thietbi" Type="String" />
               <asp:Parameter Name="Soluong" Type="String" />
               <asp:Parameter Name="Congsuat" Type="String" />
              <asp:Parameter Name="Donvi" Type="String" />
           </InsertParameters>
          
      </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource_XLsp" runat="server" 
            ConnectionString="<%$ ConnectionStrings:QLMTConnectionString %>" 
            SelectCommand="SELECT [mstb], [TenDN], [Nam], [Thietbi], [Soluong], [Congsua], [Donvi] FROM [Dinhhuong]">
        </asp:SqlDataSource>
        
         <asp:SqlDataSource ID="sp_dn" runat="server" 
           ConnectionString="<%$ ConnectionStrings:QLMTConnectionString %>" 
           SelectCommand="SELECT * FROM [Doanhnghiep] where Madnghiep=@Madnghiep">
            <SelectParameters>
        <asp:QueryStringParameter Name="Madnghiep" QueryStringField="_iddn"  ConvertEmptyStringToNull="true"/>
     </SelectParameters>
         </asp:SqlDataSource>
        
               <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditor1" runat="server" TextBoxStyle-Width="200px" />
       <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditor2" runat="server" TextBoxStyle-Width="150px" />
       <telerik:GridDropDownListColumnEditor ID="GridDropDownColumnEditor1" runat="server" DropDownStyle-Width="110px" />
       <telerik:GridNumericColumnEditor ID="GridNumericColumnEditor1" runat="server" NumericTextBox-Width="40px" />
    </div>
    </form>
</body>
</html>
